package imPro;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import javax.swing.JPanel;

/**
 *
 * @author Ragnar
 */
public class ImPanel extends JPanel
{
    private Image image;
    private LabeledObject labeledObject;
    
    public ImPanel()
    {
        this.image          = null;
        this.labeledObject  = null;
    }
    
    public void setImage(Image img)
    {
        this.image = img;
        this.repaint();
    }
    
    public void setLabeledObject(LabeledObject lo)
    {
        this.labeledObject = lo;
        this.repaint();
    }
    
    public void paintComponent(Graphics g)
    {
        super.paintComponent(g);
        if (this.image != null) 
        {
            ((Graphics2D)g).drawImage(this.image, null, this);
        }
        
        if (this.labeledObject != null)
        {
            ((Graphics2D)g).setColor(Color.green);
            ((Graphics2D)g).drawOval(this.labeledObject.getxPos(), this.labeledObject.getyPos(), this.labeledObject.getWidth(), this.labeledObject.getWidth());
        }
    }
}
